package com.ddf.publics.service.impl;

import com.ddf.publics.entity.Repayment;
import com.ddf.publics.dao.RepaymentDao;
import com.ddf.publics.service.RepaymentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 还款记录表(Repayment)表服务实现类
 *
 * @author makejava
 * @since 2020-06-22 10:56:48
 */
@Service("repaymentService")
public class RepaymentServiceImpl implements RepaymentService {
    @Resource
    private RepaymentDao repaymentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param rId 主键
     * @return 实例对象
     */
    @Override
    public Repayment queryById(Integer rId) {
        return this.repaymentDao.queryById(rId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Repayment> queryAllByLimit(int offset, int limit) {
        return this.repaymentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param repayment 实例对象
     * @return 实例对象
     */
    @Override
    public Repayment insert(Repayment repayment) {
        this.repaymentDao.insert(repayment);
        return repayment;
    }

    /**
     * 修改数据
     *
     * @param repayment 实例对象
     * @return 实例对象
     */
    @Override
    public Repayment update(Repayment repayment) {
        this.repaymentDao.update(repayment);
        return this.queryById(repayment.getRId());
    }

    /**
     * 通过主键删除数据
     *
     * @param rId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer rId) {
        return this.repaymentDao.deleteById(rId) > 0;
    }
}